package com.itboye.ihomebank.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.ihomebank.base.BaseNetRepository;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.bean.UpdateBean;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

import com.itboye.ihomebank.bean.UpdateVersionBean;
import com.itboye.ihomebank.net.BaseErrorListener;
import com.itboye.ihomebank.net.BaseSuccessReqListener;
import com.itboye.ihomebank.net.ByJsonRequest.Builder;

/**
 * Created by boye009 on 2017/1/5.
 */

public class UpdateResponsitory extends BaseNetRepository {
    String api = "100";
    String UpdateVersion = "BY_Config_version";

    public UpdateResponsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }


    public void setUpdateVersion(UpdateVersionBean bean) {
        Type type = new TypeToken<UpdateVersionBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("api_ver", apiVer);
        map.put("app_type", "android");

        (new Builder<UpdateVersionBean>())
                .setTypeVerParamsAndReturnClass(UpdateVersion, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<UpdateVersionBean>(getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
